//microcommand define -lnnbot-export-microcommands
let AdmZip
inject(["database"])
signature("", { authority: 3, checkArgCount: true, checkUnknown: true, hidden: true, slash: false })
action(async ({ session }) => {
await session.onebot?._get("get_group_root_files", { group_id: session.guildId }).then(l => l.files.find(f => f.file_name === "microcommands-dump.zip")).then(f => f && session.onebot._get("delete_group_file", { group_id: session.guildId, file_id: f.file_id, busid: f.busid })).catch(() => {})
const zip = new (AdmZip ??= (await import("adm-zip")).default)()
for (const { name, code } of await ctx.database.get("microcommand")) zip.addFile(name.replace(/[\\/:*?"<>|]/, "_") + ".js", Buffer.from(`//microcommand define ${name}\n` + code, "utf8"))
return h.file(zip.toBuffer(), "application/zip", { title: "microcommands-dump.zip" })
})